#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>

// #include <iostream>
#include <thread>

#include "NetComm.h"
#include "Log_Client.h"

#include "CJsonObject.hpp"
#include "SysCtrl.h"
#include "ShowImage.h"
#include "AlsaOpt.h"

void* NetThreadRoutine(void * arg)
{
    AddLog(INFO_LEVEL, "main", "NetThreadRoutine()\n");
    CNetComm netCommObj;
	
    // 另一个处理方式
    netCommObj.TcpServerHttp();

	return (void*)0;
}


int main() 
{
    printf("New 2025 Happy New Year 01/08 21:46 WesDay LJH\n");
    AddLog(INFO_LEVEL, "main", "Hello this is main()");

    // 1. 启动网络线程
    pthread_t netThreadId;
    pthread_create(&netThreadId, NULL, NetThreadRoutine, NULL);
    pthread_detach(netThreadId);

    // 2. 启动HMI触屏测试线程
    std::thread hmiThreadObj(HMI_CtrlTestLoop);
    hmiThreadObj.detach();

    // 3. 启动LCD显示测试线程
    int intervalTime = 1;   // 每张图片间隔时间 单位：秒
    int nLoopCnt = -1;      // 循环次数  -1 表示无限循环
    std::thread lcdThreadObj(ShowAllPhotoInDir, "/root/2025/6818Fundamental/AllPics", intervalTime, nLoopCnt);
    lcdThreadObj.detach();


    // OtherTools\AlsaTools
    PlayWavFile("/root/2025/alsaTest/audioFile/WindowsOnAudio.wav");

    
    while(1)
    {
        // 不让程序结束
        sleep(1);
    }

    return 0;
}


